From 3caa8e74046c5c1b3a291dc87eff42d7ddecbecf Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 2 Mar 2005 01:54:05 +0000 Subject: [PATCH] eAccelerator caching support, patches from Jamie Bliss --- config/index.php | 21 +++++++++++++++++--- includes/DefaultSettings.php | 16 ++++++++++++++- includes/ObjectCache.php | 38 ++++++++++++++++++++++++++++++++++++ includes/Setup.php | 6 ++++++ 4 files changed, 77 insertions(+), 4 deletions(-) diff --git a/config/index.php b/config/index.php index 7de46de2f2..fe366ead1f 100644 --- a/config/index.php +++ b/config/index.php @@ -273,8 +273,14 @@ if( $conf->zlib ) { $conf->turck = function_exists( 'mmcache_get' ); if ( $conf->turck ) { print "
  • Turck MMCache installed
  • \n"; -} else { - print "
  • Turck MMCache not installed, " . +} +$conf->eaccel = function_exists( 'eaccelerator_get' ); +if ( $conf->eaccel ) { + $conf->turck = 'eaccelerator'; + print "
  • eAccelerator installed
  • \n"; +} +if (!$conf->turck && !$conf->eaccel) { + print "
  • Neither Turck MMCache nor eAccelerator are installed, " . "can't use object caching functions
  • \n"; } @@ -748,12 +754,19 @@ if( count( $errs ) ) { echo ""; } ?> + eaccel ) { + echo "
  • "; + aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" ); + echo "
  • "; + } + ?>
  • - Using a shared memory system such as Turck MMCache or Memcached will speed + Using a shared memory system such as Turck MMCache, eAccelerator, or Memcached will speed up MediaWiki significantly. Memcached is the best solution but needs to be installed. Specify the server addresses and ports in a comma-separted list. Only use Turck shared memory if the wiki will be running on a single Apache server. @@ -950,6 +963,7 @@ function writeLocalSettings( $conf ) { $mcservers = var_export( $conf->MCServerArray, true ); break; case 'turck': + case 'eaccel': $memcached = 'false'; $mcservers = 'array()'; $turck = ''; @@ -1071,6 +1085,7 @@ if ( \$wgCommandLineMode ) { \$wgUseMemCached = $memcached; \$wgMemCachedServers = $mcservers; {$turck}\$wgUseTurckShm = function_exists( 'mmcache_get' ) && php_sapi_name() == 'apache'; +{$turck}\$wgUseEAccelShm = function_exists( 'eaccelerator_get' ) && php_sapi_name() == 'apache'; ## To enable image uploads, make sure the 'images' directory ## is writable, then uncomment this: diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 3bf5b5441c..4f8da743e5 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -308,12 +308,26 @@ $wgLinkCacheMemcached = false; # Not fully tested * Turck MMCache shared memory * You can use this for persistent caching where your wiki runs on a single * server. Enabled by default if Turck is installed. Mutually exclusive with - * memcached, memcached is used if both are specified. + * memcached and eAccelerator, the preference order priorities being memcached first, + * Turck MMCache second, and eAccelerator third. * * @global bool $wgUseTurckShm Enable or disabled Turck MMCache */ $wgUseTurckShm = false; +/** + * eAccelerator shared memory + * You can use this for persistent caching where your wiki runs on a single + * server. Enabled by default if eAccelerator is installed. Mutually exclusive with + * memcached and Turck MMCache, the preference order being memcached first, + * Turck MMCache second, and eAccelerator third. + * + * Most of the code to support this is directly copied from the Turck code. + * + * @global bool $wgUseEAccelShm Enable or disabled eAccelerator + */ +$wgUseEAccelShm = false; + # Language settings # diff --git a/includes/ObjectCache.php b/includes/ObjectCache.php index e1d13f89c2..b4bb22b59e 100644 --- a/includes/ObjectCache.php +++ b/includes/ObjectCache.php @@ -454,4 +454,42 @@ class TurckBagOStuff extends BagOStuff { return true; } } + +/** + * This is a wrapper for eAccelerator's shared memory functions. + * + * This is basically identical to the Turck MMCache version, + * mostly because eAccelerator is based on Turck MMCache. + * + * @package MediaWiki + */ +class eAccelBagOStuff extends BagOStuff { + function get($key) { + $val = eaccelerator_get( $key ); + if ( is_string( $val ) ) { + $val = unserialize( $val ); + } + return $val; + } + + function set($key, $value, $exptime=0) { + eaccelerator_put( $key, serialize( $value ), $exptime ); + return true; + } + + function delete($key, $time=0) { + eaccelerator_rm( $key ); + return true; + } + + function lock($key, $waitTimeout = 0 ) { + eaccelerator_lock( $key ); + return true; + } + + function unlock($key) { + eaccelerator_unlock( $key ); + return true; + } +} ?> diff --git a/includes/Setup.php b/includes/Setup.php index b4531309de..2d48329680 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -145,6 +145,12 @@ if( $wgUseMemCached ) { require_once( 'ObjectCache.php' ); $wgMemc = new TurckBagOStuff; $messageMemc = &$wgMemc; +} elseif ( $wgUseEAccelShm ) { + # eAccelerator shared memory + # + require_once( 'ObjectCache.php' ); + $wgMemc = new eAccelBagOStuff; + $messageMemc = &$wgMemc; } else { /** * No shared memory -- 2.20.1